#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

// 2779. 数组的最大美丽值
// https://leetcode.cn/problems/maximum-beauty-of-an-array-after-applying-operation/description/

class Solution {
public:
    int maximumBeauty(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());
        int ans = 0;
        int left = 0;
        int n = nums.size();
        k *= 2;
        for (int i = 0; i < n; i++)
        {
            int curNum = nums[i];
            while(curNum - k > nums[left]){
                ++left;
            }
            ans = max(ans, i - left + 1);
        }
        return ans;
    }
};

int main()
{
    return 0;
}